$().ready(function(){
    let nav = getSearch('nav');
    if(nav == 5){
        let classId = getSearch('class');
        let navList = layoutMain;
        let item = {};
        for(let i in layoutMain.list){
            if(classId == layoutMain.list[i].id){
                item = layoutMain.list[i]
            }
        }
        var navHtml = '';
        var navTitle = '<a href="index.html">首页</a>';
        navTitle += '<a href="index.html">'+navList.name+'</a>';
        navTitle += '<a href="">'+item.class_name+'</a>';
        $('#breadcream').html(navTitle);
        console.log(item.content);
        for(var j in item.content){
            console.log(item.content);
            navHtml += '<div class="nav-item-box"><div class="nav-items">';
            navHtml += `<a href="rich-text.html?nav=${layoutMain.id}&class=${classId}&item=${item.content[j].id}">`;
            navHtml += '<div class="item-content">';
            navHtml += '<p class="title-cn">'+item.content[j].title+'</p>';
            navHtml += '<p class="title-en">'+item.content[j].english+'p</p>';
            navHtml += ' </div><img src="img/arrow.png" alt=""> </a></div></div>'
        }
        $('#navList').html(navHtml);
    }else if(nav == 3){
        let navList;
        for(let i in mainList){
            if(nav == mainList[i].id){
                // console.log(mainList[i]);
                navList = mainList[i];
            }
        }
        console.log(navList);
        var navHtml = '';
        var navTitle = '<a href="index.html">首页</a>';
        navTitle += '<a href="nav-page.html?nav='+nav+'">'+navList.name+'</a>';
        $('#breadcream').html(navTitle);
        console.log(navList);
        for(var i in navList.list){
            navHtml += '<div class="nav-item-box"><div class="nav-items">';
            navHtml += '<a href="'+navList.list[i].link+'?nav='+navList.id+'&item='+navList.list[i].id+'">';
            navHtml += '<div class="item-content">';
            navHtml += '<p class="title-cn">'+navList.list[i].title+'</p>';
            navHtml += '<p class="title-en">'+navList.list[i].english_title+'</p>';
            navHtml += ' </div><img src="img/arrow.png" alt=""> </a></div></div>'
        }
        $('#navList').html(navHtml);
    }else if(nav == 6){
        let navList = footerList;
        let list = footerList.list;
        var navHtml = '';
        var navTitle = '<a href="index.html">首页</a>';
        navTitle += '<a href="nav-page.html?nav='+nav+'">'+footerList.name+'</a>';
        $('#breadcream').html(navTitle);
        for(let i in list){
            navHtml += '<div class="nav-item-box"><div class="nav-items">';
            navHtml += '<a href="'+list[i].link+'?nav='+nav+'&item='+list[i].id+'">';
            navHtml += '<div class="item-content">';
            navHtml += '<p class="title-cn">'+list[i].name+'</p>';
            navHtml += '<p class="title-en">'+list[i].en+'</p>';
            navHtml += ' </div><img src="img/arrow.png" alt=""> </a></div></div>'
        }
        $('#navList').html(navHtml);

    }else{
        let navList;
        for(let i in mainList){
            if(nav == mainList[i].id){
                // console.log(mainList[i]);
                navList = mainList[i];
            }
        }
        var navHtml = '';
        var navTitle = '<a href="index.html">首页</a>';
            navTitle += '<a href="nav-page.html?nav='+nav+'">'+navList.name+'</a>';
        $('#breadcream').html(navTitle);
        for(var i in navList.list){
            navHtml += '<div class="nav-item-box"><div class="nav-items">';
            navHtml += '<a href="'+navList.list[i].link+'?nav='+navList.id+'&item='+navList.list[i].id+'">';
            navHtml += '<div class="item-content">';
            navHtml += '<p class="title-cn">'+navList.list[i].name+'</p>';
            navHtml += '<p class="title-en">'+navList.list[i].en+'</p>';
            navHtml += ' </div><img src="img/arrow.png" alt=""> </a></div></div>'
        }
        $('#navList').html(navHtml);
    }
})
